package payrechargelogic

import (
	"context"
	model "gitee.com/liuxuezhan/ar-platform/assets-rpc/internal/dao/model/recharge"
	"gitee.com/liuxuezhan/ar-platform/assets-rpc/pkg/xerrors"

	"gitee.com/liuxuezhan/ar-platform/assets-rpc/internal/svc"
	"gitee.com/liuxuezhan/ar-platform/assets-rpc/rpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type RechargeVipLevelDeleteLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewRechargeVipLevelDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RechargeVipLevelDeleteLogic {
	return &RechargeVipLevelDeleteLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *RechargeVipLevelDeleteLogic) RechargeVipLevelDelete(in *rpc.RechargeVipLevelDeleteRequest) (*rpc.CommonResponse, error) {
	var CommonResp rpc.CommonResp

	err := model.NewRechargeVipModel(l.ctx, l.svcCtx.Db).DeleteRechargeVip(in.Id)
	if err != nil {
		CommonResp.Code = xerrors.DBError
		CommonResp.Message = "Database operation error"
		return &rpc.CommonResponse{
			CommonResp: &CommonResp,
		}, err
	}

	CommonResp.Message = "Success"
	return &rpc.CommonResponse{
		CommonResp: &CommonResp,
	}, nil
}
